/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.cs.mailbox.MailItem.CustomMetadata;
/*    */ import com.zimbra.cs.mailbox.MailItem.Type;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class SetCustomData
/*    */   extends RedoableOp
/*    */ {
/*    */   private int itemId;
/*    */   private MailItem.Type type;
/*    */   private MailItem.CustomMetadata custom;
/*    */   
/*    */   public SetCustomData()
/*    */   {
/* 37 */     super(MailboxOperation.SetCustomData);
/*    */   }
/*    */   
/*    */   public SetCustomData(int mailboxId, int id, MailItem.Type type, MailItem.CustomMetadata custom) {
/* 41 */     this();
/* 42 */     setMailboxId(mailboxId);
/* 43 */     this.itemId = id;
/* 44 */     this.type = type;
/* 45 */     this.custom = custom;
/*    */   }
/*    */   
/*    */   protected String getPrintableData()
/*    */   {
/* 50 */     StringBuffer sb = new StringBuffer("id=");
/* 51 */     sb.append(this.itemId).append(", data=").append(this.custom);
/* 52 */     return sb.toString();
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException
/*    */   {
/* 57 */     out.writeInt(this.itemId);
/* 58 */     out.writeByte(this.type.toByte());
/* 59 */     out.writeUTF(this.custom.getSectionKey());
/* 60 */     out.writeUTF(this.custom.getSerializedValue());
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException
/*    */   {
/* 65 */     this.itemId = in.readInt();
/* 66 */     this.type = MailItem.Type.of(in.readByte());
/*    */     try {
/* 68 */       String extendedKey = in.readUTF();
/* 69 */       this.custom = new MailItem.CustomMetadata(extendedKey, in.readUTF());
/*    */     } catch (ServiceException e) {
/* 71 */       mLog.warn("could not deserialize custom metadata for folder", e);
/*    */     }
/*    */   }
/*    */   
/*    */   public void redo() throws Exception
/*    */   {
/* 77 */     Mailbox mailbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/* 78 */     mailbox.setCustomData(getOperationContext(), this.itemId, this.type, this.custom);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/SetCustomData.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */